<script>
	$(function() {
		$("#<?php echo $this->name ?>" ).datepicker({
			dateFormat: "dd-M-yy"
		});
		$("#<?php echo $this->name ?>" ).change(function(){			
			var newDate = Date.parseExact($("#<?php echo $this->name ?>" ).val(),"d-MMM-yyyy");
			if (newDate == null){
				alert("<?php echo Yii::t("dialog","Format tanggal salah !"); ?>");
				$("#<?php echo $this->name ?>" ).val(Date.today().toString("d-MMM-yyyy"));
				$("#<?php $this->name ?>" ).focus();
				$(this).select();
			}
		});
	});	
	function <?php echo $this->name ?>_imgDatePicker_click(){
		if ($("#ui-datepicker-div").css("display") == "block" ){
			$("#<?php echo $this->name ?>" ).datepicker( "hide" );
		}else{
			$("#<?php echo $this->name ?>" ).datepicker( "show" );
		}
	}
</script>
<?php
	//$options = $this->options;
	//$optionsKey = array_keys($options);
	
	$compHtml="<div style='display:inline'>";		
	$labelValue = $this->label["value"];
	if ( $labelValue != ""){
		//create input text with label
		$labelOpt = $this->label["htmlOptions"];
		$compHtml .="<label $labelOpt>" .$this->label["value"] ."</label>";
	}
	
	$compHtml.="<input type='text' name='$this->name' id='$this->name' value='$this->value' style='margin-right:2px' $this->htmlOptions />";
	$compHtml .= "<img class='imgBtn' style='margin:0px;' src='images/icon/ic_calendar.png' onClick='". $this->name . "_imgDatePicker_click()'/>";
	$compHtml .= "</div>";
	echo $compHtml;	
?>
